﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Windows.Forms;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UITest.Extension;
using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;
using Microsoft.VisualStudio.TestTools.UITesting.WinControls;


namespace CalculatorSillyIntro
{
    /// <summary>
    /// Summary description for CodedUITest1
    /// </summary>
    [CodedUITest]
    public class CodedUITest1
    {
        public CodedUITest1()
        {
        }

        [TestMethod]
        public void FirstAdditionTest()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.

            this.map = new UIMap();
            this.map.TeatAddition();
            this.UIMap.AssertAddition();
        }


        [TestMethod]
        public void TestAddition()
        {


            this.map = new UIMap();




            //map.Write45OnCaluclator();
            Mouse.Click(this.map.UICalculatorWindow.UIItem4Window.UIItem4Button);
            Mouse.Click(this.map.UICalculatorWindow.UIItemWindow.UIItemButton); // +
            Mouse.Click(this.map.UICalculatorWindow.UIItem5Window.UIItem5Button); // 5
            Mouse.Click(this.map.UICalculatorWindow.UIItemWindow1.UIItemButton); // = 



            Assert.IsTrue(int.Parse(this.UIMap.UICalculatorWindow.UIItem9Window.UIItem9Text.DisplayText) == 9, "Error in addition");

            


        }


        [TestMethod]
        public void TestAdditionUsingNewUIMap()
        {
            CalculatorManipulationUIMapClasses.CalculatorManipulationUIMap newMap = new CalculatorManipulationUIMapClasses.CalculatorManipulationUIMap();
            
            newMap.Click1();
            newMap.ClickOnPlus();
            newMap.Click3();
            newMap.ClickOnEqual();

            Assert.IsTrue(int.Parse(newMap.ResultText()) == 4, "Error in addition");



        }

        [TestMethod]
        public void TestAdditionUsingNewUIMap2()
        {

            CalculatorManipulationUIMapClasses.CalculatorManipulationUIMap newMap = new CalculatorManipulationUIMapClasses.CalculatorManipulationUIMap();

            newMap.Click3();
            newMap.ClickOnMinus();
            newMap.Click1();
            newMap.ClickOnEqual();

            Assert.IsTrue(int.Parse(newMap.ResultText()) == 2, "Error in addition");


        }




        

        #region Additional test attributes

        // You can use the following additional attributes as you write your tests:

        ////Use TestInitialize to run code before running each test 
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{        
        //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        //}

        ////Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{        
        //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        //}

        #endregion

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
        private TestContext testContextInstance;

        public UIMap UIMap
        {
            get
            {
                if ((this.map == null))
                {
                    this.map = new UIMap();
                }

                return this.map;
            }
        }

        private UIMap map;
    }
}
